<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <title>燃情世界杯</title>
    <link rel="stylesheet" href="css/reset.css">
    <link rel="stylesheet" href="css/index.css">
    <script src="js/jquery-1.11.3.min.js"></script>
    <script src="js/zepto.min.js"></script>
    <script src="js/script.js"></script>
    <script src="js/iscroll-zoom.js"></script>
    <!--[if lt IE 9]>
    <script src="js/html5shiv.min.js"></script>
    <script src="js/respond.min.js"></script>
    <![endif]-->
    <style>

    </style>
</head>

<body>
    <div class="bg" style="background-image: url('images/index/zubg.jpg')">
        <div class="pic">
            <div>
                <div class="pic_cont">
                    <img src="images/index/ren.jpg" alt="" class="up_img" id="img-upload" />
                    <div class="upload-img"></div>
                    <div class="upload-btn btn-old"><input type="file" name="" id=""></div>
                    <div class="pic_inner">
                        <div class="pic_pos">
                            <img src="images/index/zhao.png" alt="" />
                            <p> 上传照片 </p>
                        </div>
                    </div>
                </div>
                <div class="que">
                    <a href="#" id="btn"> 确认 </a>
                </div>
            </div>
        </div>
    </div>

</body>
<script src="js/index.js"></script>
<script language="JavaScript">

    //获得当前显示的这个图片 并存到session中  然后跳转页面
    $("#btn").click(function () {
        let imgurl=''
        let upoding = $("#img-upload").attr('src');
     

        //转换64位编码
        function image2Base64(img) {
            var canvas = document.createElement("canvas");
            canvas.width = img.width;
            canvas.height = img.height;
            var ctx = canvas.getContext("2d");
            ctx.drawImage(img, 0, 0, img.width, img.height);
            var dataURL = canvas.toDataURL("image/png");
            return dataURL;
        }
        function getImgBase64() {
            var img = new Image();
            img.src = upoding;
            img.onload=function(){
                imgurl=image2Base64(img);
                /*存入session*/
                window.sessionStorage.setItem("2", imgurl);
            }   
        }
        getImgBase64();
        window.location.href="photograph.html";
    })

  
</script>

</html>